#_*_ coding:UTF-8 _*_
__author__ = 'shaowei'

import commands


shell_build_setting = "xcodebuild -showBuildSettings"
shell_build_list = "xcodebuild -list"


def get_build_settings():
		status, output = commands.getstatusoutput(shell_build_setting)
		arr_param = output.split("\n")
		# del arr_param[0]
		# arr_param.pop()
		dic_param = {}

		for param in arr_param:
			# print "param:", param
			if " = " in param:
				key, value = param.split(" = ")
				key = key.strip()
				value = value.strip()
				dic_param[key] = value
			else:
				# print "debug--param_invalid:", param
				pass

		return dic_param


def get_configuration_list():
	status, output = commands.getstatusoutput(shell_build_list)
	arr_param = output.split("\n")
	configuration_list = []

	start_get = False
	for item in arr_param:
		item_strip = item.strip()
		# print len(item_strip), ":", item
		if start_get:
			if len(item_strip) == 0:
				break
			else:
				configuration_list.append(item_strip)
		else:
			if item_strip.startswith("Build Configurations"):
				start_get = True

	return configuration_list


